package com.dm.entity;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * @author hqw521@qq.com
 * @date 2018/11/12 20:35
 */
@Entity
@Table(name = "dm_record", schema = "dm", catalog = "")
public class Record {
    private int recordId;
    private Integer fileId;
    private Integer folderId;
    private Integer userId;
    private String operation;
    private Timestamp createTime;
    private Timestamp updateTime;
    private File dmFileByFileId;
    private Folder dmFolderByFolderId;
    private User dmUserByUserId;

    @Id
    @Column(name = "record_id", nullable = false)
    public int getRecordId() {
        return recordId;
    }

    public void setRecordId(int recordId) {
        this.recordId = recordId;
    }

    @Basic
    @Column(name = "file_id", nullable = true)
    public Integer getFileId() {
        return fileId;
    }

    public void setFileId(Integer fileId) {
        this.fileId = fileId;
    }

    @Basic
    @Column(name = "folder_id", nullable = true)
    public Integer getFolderId() {
        return folderId;
    }

    public void setFolderId(Integer folderId) {
        this.folderId = folderId;
    }

    @Basic
    @Column(name = "user_id", nullable = true)
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "operation", nullable = true, length = 8)
    public String getOperation() {
        return operation;
    }

    public void setOperation(String operation) {
        this.operation = operation;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time", nullable = true)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @ManyToOne
    @JoinColumn(name = "file_id", referencedColumnName = "file_id", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    public File getDmFileByFileId() {
        return dmFileByFileId;
    }

    public void setDmFileByFileId(File dmFileByFileId) {
        this.dmFileByFileId = dmFileByFileId;
    }

    @ManyToOne
    @JoinColumn(name = "folder_id", referencedColumnName = "folder_id", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    public Folder getDmFolderByFolderId() {
        return dmFolderByFolderId;
    }

    public void setDmFolderByFolderId(Folder dmFolderByFolderId) {
        this.dmFolderByFolderId = dmFolderByFolderId;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    public User getDmUserByUserId() {
        return dmUserByUserId;
    }

    public void setDmUserByUserId(User dmUserByUserId) {
        this.dmUserByUserId = dmUserByUserId;
    }
}
